using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class GameObjectUtils
{
	public static void addGameObjectSort (List<GameObject> gameObjectSort, GameObject gameObject)
	{
		string name = gameObject.name;
		int count = gameObjectSort.Count;
		for (int i = 0; i < count; i++) {
			if (name.CompareTo (gameObjectSort [i].name) < 0) {
				gameObjectSort.Insert (i, gameObject);
				return;
			}
		}
		
		gameObjectSort.Add (gameObject);
	}
	
	public static List<GameObject> getGameObjectSort (List<GameObject> gameObjectList)
	{
		List<GameObject> gameObjectSort = new List<GameObject> (gameObjectList.Count);
		foreach (GameObject gameObject in gameObjectList) {
			addGameObjectSort (gameObjectSort, gameObject);
		}
		
		return gameObjectSort;
	}
	
	public static List<GameObject> getChildrenGameObjectSort (GameObject gameObject)
	{
		List<GameObject> gameObjectSort = new List<GameObject> ();
		foreach (Transform child in gameObject.transform) {
			addGameObjectSort (gameObjectSort, child.gameObject);
		}
		
		return gameObjectSort;
	}
}

